<?php
/**
 * @Author: rocky
 * @Copyright: 广州拓冠科技 <http://my8m.com>
 * Date: 2019/7/22
 * Time: 11:11
 */


namespace app\shop\resource;



use app\common\model\LpJiel;
use app\common\model\LpOrder;
use app\common\resource\BaseResource;
use app\shop\model\ShopGoods;
use app\shop\model\ShopGoodsSpec;
use app\shop\model\ShopOrderGoods;

class InviteSpellResource extends BaseResource
{
    public function toArray($data)
    {
        foreach ($data['order'] as $order){
            if($order['uid'] == $data['uid']){

                $orderGood = ShopOrderGoods::where('order_id',$order['id'])->find();
                break;
            }
        }
        return [
            'pt_id' => $data['id'],
            'uid'=>$data['uid'],
            'num' => $data['num'],
            'start_time' => $data['start_time'],
            'end_time' => $data['end_time'],
            'q_num' => $data['num'] - $data['join_num'],
            'price' => $data['good']['price'],
            'spell_price' =>$orderGood['price'],
            'spec_name' =>$orderGood['spec_name'],
            'spec_id' =>$orderGood['spec_id'],
            'title' => $data['good']['title'],
            'logo' => $data['good']['logo'],
            'good_id' => $data['good']['id'],
            'user' => SpellUserJoinResource::collection($data['order']),
            'spell_text' => sysconf('spell_text|raw')
        ];
    }
}